package com.xiaoshuidi.cloud.module.report.controller.datamanage;

import com.xiaoshuidi.cloud.framework.common.pojo.CommonResult;
import com.xiaoshuidi.cloud.module.report.controller.datamanage.vo.*;
import com.xiaoshuidi.cloud.module.report.enums.ApiConstants;
import com.xiaoshuidi.cloud.module.report.service.datamanage.LeaseAnalysisService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.LinkedHashMap;

import static com.xiaoshuidi.cloud.framework.common.pojo.CommonResult.success;

/**
 * 租约分析
 */
@Slf4j
@Validated
@RestController
@RequestMapping(ApiConstants.DATA_MANAGE + "/lease-analysis")
public class LeaseAnalysisController {

    @Resource
    private LeaseAnalysisService leaseAnalysisService;

    /**
     * 租赁合同分析
     *
     * @param vo
     * @return
     */
    @PostMapping("/contract-analysis")
    public CommonResult<List<LeaseContractAnalysisRespVO>> leaseContractAnalysis(@RequestBody LeaseAnalysisReqVO vo) {
        return success(leaseAnalysisService.leaseContractAnalysis(vo));
    }

    /**
     * 租客签约分析
     *
     * @param vo
     * @return
     */
    @PostMapping("/sign-analysis")
    public CommonResult<LeaseSignContractRespVO> leaseSignContractsAnalysis(@RequestBody LeaseAnalysisReqVO vo) {
        return success(leaseAnalysisService.leaseSignContractsAnalysis(vo));
    }


    /**
     * 租客签约分析 -> 租期时长
     *
     * @param vo
     * @return
     */
    @PostMapping("/period-analysis")
    public CommonResult<LinkedHashMap<String, Long>> leasePeriodAnalysis(@RequestBody LeaseAnalysisReqVO vo) {
        return success(leaseAnalysisService.leasePeriodAnalysis(vo));
    }

    /**
     * 租客签约分析 -> 年龄分布
     *
     * @param vo
     * @return
     */
    @PostMapping("/age-analysis")
    public CommonResult<LinkedHashMap<String, Long>> leaseAgeAnalysis(@RequestBody LeaseAnalysisReqVO vo) {
        return success(leaseAnalysisService.leaseAgeAnalysis(vo));
    }

    /**
     * 业主合同分析
     *
     * @return
     */
    @PostMapping("/owner-contract-analysis")
    public CommonResult<List<OwnerContractAnalysisRespVO>> ownerContractAnalysis(@RequestBody OwnerAnalysisReqVO vo) {
        return success(leaseAnalysisService.ownerContractAnalysis(vo));
    }

    /**
     * 业主签约分析
     *
     * @return
     */
    @PostMapping("/owner-sign-contract-analysis")
    public CommonResult<OwnersSignContractRespVO> ownersSignContractsAnalysis(@RequestBody OwnerAnalysisReqVO vo) {
        return success(leaseAnalysisService.ownersSignContractsAnalysis(vo));
    }


    /**
     * 业主年龄分析
     *
     * @return
     */
    @PostMapping("/owner-age-analysis")
    public CommonResult<LinkedHashMap<String, Long>> ownersAgeAnalysis(@RequestBody OwnerAnalysisReqVO vo) {
        return success(leaseAnalysisService.ownersAgeAnalysis(vo));
    }


    /**
     * 业主租期时长分析
     *
     * @return
     */
    @PostMapping("/owner-period-analysis")
    public CommonResult<LinkedHashMap<String, Long>> ownersPeriodAnalysis(@RequestBody OwnerAnalysisReqVO vo) {
        return success(leaseAnalysisService.ownersPeriodAnalysis(vo));
    }
}
